<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
        
        let arr1 = [1,3,5,7,9]
        let arr2 = [2,4,6,8,10]
        console.log(arr1)
        // 将数组展开进行输出
        console.log(...arr1)

        // 连接数组
        let arr3 = [...arr1, ...arr2]
        console.log(arr3)

        // 批量接收参数
        function sum(...numbers){
            console.log(numbers)
            // 对数组进行求和，reduce接收两个参数，一个是原本的值，一个是当前遍历的值
            return numbers.reduce((preValue, currentValue)=>{
                return preValue + currentValue
            })
        }
        console.log(sum(1,2,3,4))

        let person = {name:'tom', age:18}
        // ...不能用于直接展开一个对象，但在{}内，可以用于克隆一个对象
        // console.log(...person) 此句会报错
        let person2 = {...person}
        console.log(person2)

    </script>
</body>
</html>